Teacher Version

Hero Image
Hero Image

Using Comments

Using Comments

As you continue programming, you may have to write larger programs for complex tasks. When faced with a complex task, you can break it into multiple simple behaviors. Then you can visually write out these simple behaviors as comments. These comments will help guide you while writing your program. If the program is long. It is good practice to break the program up into as many sections as possible. Test each section one at a time. Once all sections are working as expected, you then can bring them all together to form one large complex task.

In today's industry, it is common that you may be asked to fix another programmer's code. The code that you are tasked to fix my not always be commented or planed out. If you cannot clearly see what is wrong with the program, a good place to start would be by commenting sections of code out until you find the problem. Using comments to skip over sections of code is a great way to see where your program is broken.

Also, When you write more advanced programs you will not always want to delete sections of your code. Imagine writing a very long program that is not exactly doing what you wanted. You can start commenting out sections of your code until you find out which command could be causing the issue. That way, once you find and fix the issue, you will be able to uncomment the code that you know that works.

In this activity, you will be given a list of instructions that your program must follow. There will be commands with in the program that are not needed. You need to find the commands that are not needed and comment them out. After you comment out the "extra" commands, your program will be able to carry out the steps of the program correctly.

Debugging Program: c_DebugProgramFlow.rbg

© 2016 Robomatter, Inc.

Portions of this product are manufactured under license from Carnegie Mellon University.